﻿using System;
using System.ComponentModel.DataAnnotations;

namespace MeetingAssistant.ViewModel.Member
{
    public class UserVM
    {
        public UserVM()
        {
            Enabled = true;
        }

        [Display(Name = "用户ID")]
        public int Id { get; set; }

        [Required(ErrorMessage = "登录名称不能为空")]
        [Display(Name = "登录名称")]
        public string UserName { get; set; }

        [Required(ErrorMessage = "登录密码不能为空")]
        [Display(Name = "密码")]
        public string Password { get; set; }

        [Required(ErrorMessage = "真实姓名不能为空")]
        [Display(Name = "真实姓名")]
        public string TrueName { get; set; }

        [Required]
        [Display(Name = "性别")]
        public bool Sex { get; set; }
        public string StrSex
        {
            get
            {
                return Sex == true ? "男" : "女";
            }
        }

        [Required(ErrorMessage = "身份证号不能为空")]
        [Display(Name = "身份证号")]
        public string IdentityNumber { get; set; }

        [Display(Name = "电子邮件")]
        [Required(ErrorMessage = "电子邮件不能为空")]
        [DataType(DataType.EmailAddress)]
        [MaxLength(50, ErrorMessage = "Email地址长度不能超过50个字符")]
        [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9._]+\.[A-Za-z]{2,4}", ErrorMessage = "电子邮件格式不正确")]
        public string Email { get; set; }

        [Display(Name = "电话")]
        [MaxLength(13, ErrorMessage = "电话长度不能超过13个字符")]
        public string Phone { get; set; }

        [Display(Name = "个人住址")]
        [MaxLength(150, ErrorMessage = "地址长度不能超过150个字符")]
        public string Address { get; set; }

        [Required(ErrorMessage = "所属部门不能为空")]
        [Display(Name = "所属部门")]
        public string Department { get; set; }

        
        [Display(Name = "所属公司")]
        public string CompanyName { get; set; }

        [Display(Name = "是否激活")]
        public bool Enabled { get; set; }

        public string StrEnabled
        {
            get
            {
                return Enabled == true ? "是" : "否";
            }
        }

        [Display(Name = "更新时间")]
        public DateTime UpdateDate { get; set; }
        public string StrUpdateDate
        {
            get
            {
                return UpdateDate.ToString();
            }
            set { }
        }
    }
}
